package cn.lg.soar.system.auth.entity;

import cn.lg.soar.common.data.tree.ITreeSource;
import cn.lg.soar.core.util.easyexcel.converters.BooleanConverter;
import cn.lg.soar.database.base.entity.ITenantEntity;
import cn.lg.soar.database.base.entity.NumberTreeEntity;
import cn.lg.soar.database.translate.TranslateByEntity;
import cn.lg.soar.system.api.enums.OrgTypeEnum;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 组织机构
 * @author luguoxiang
 * @since 2021-01-10
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@Accessors(chain = true)
@ApiModel(value = "Org", description = "组织机构")
@TableName("lg_sys_org")
public class Org extends NumberTreeEntity<Long> implements ITenantEntity, ITreeSource<Long> {

    private static final long serialVersionUID = -652064669650119926L;

    @ApiModelProperty(value = "主键")
    @TableId
    private Long id;

    @ApiModelProperty(value = "类型")
    private OrgTypeEnum type;

    @ApiModelProperty(value = "名称")
    private String name;

    @ApiModelProperty(value = "别名")
    private String alias;

    @ApiModelProperty(value = "负责人")
    @TranslateByEntity(value = User.class, label = "nickname")
    @ExcelProperty(value = "负责人")
    private Long director;

    @ApiModelProperty(value = "描述")
    private String remark;

    @ApiModelProperty(value = "是否禁用")
    @ExcelProperty(value = "是否禁用", converter = BooleanConverter.class)
    private Boolean disabled;

    @Version
    @ApiModelProperty(value = "乐观锁")
    protected Integer version;

    @ApiModelProperty(value = "租户id")
    @JsonIgnore
    @TableField(select = false)
    private Integer tenantId;

    @Override
    public Long primaryKey() {
        return this.id;
    }


    @TranslateByEntity(Org.class)
    @Override
    public Long getParentId() {
        return parentId;
    }

}
